package com.wang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wang.entity.TbUserTask;
import com.wang.response.ResultResponse;
import com.wang.service.TbUserTaskService;
import com.wang.mapper.TbUserTaskMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 */
@Service
public class TbUserTaskServiceImpl implements TbUserTaskService{

    @Resource
    private TbUserTaskMapper tbUserTaskMapper;

    @Override
    public ResultResponse insertTbUserTask(TbUserTask tbUserTask) {
        int insert = tbUserTaskMapper.insert(tbUserTask);
        if (insert>0){
            return ResultResponse.SUCCESS();
        }else{
            return ResultResponse.FAIED(500, "失败");
        }
    }

    @Override
    public ResultResponse removeTbUserTask(Integer userTaskId) {
        int i = tbUserTaskMapper.deleteById(userTaskId);
        if (i>0){
            return ResultResponse.SUCCESS();
        }else{
            return ResultResponse.FAIED(500, "失败");
        }
    }

    @Override
    public ResultResponse findtbtask(TbUserTask tbUserTask) {
        QueryWrapper<TbUserTask> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", tbUserTask.getUserId());
        List<TbUserTask> tbUserTasks = tbUserTaskMapper.selectList(wrapper);
        return ResultResponse.SUCCESS(tbUserTasks);
    }
}




